package org.bluedream.core.module.dao.goods;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.bluedream.core.module.entity.goods.Goods;

import java.io.Serializable;
import java.util.List;

/**
 * @ClassName depItemUserDao
 * @Description TODO
 * @Author foxsand
 * @Data 17:16
 * @Version
 */
public interface GoodsDao extends BaseMapper<Goods> {

    @Override
    @Select("select clsItem.code as \"clsItem.treeCode\" , clsItem.tree_name as \"clsItem.treeName\", " +
            " brandItem.code as \"brandItem.code\" , brandItem.name as \"brandItem.name\" , " +
            " clsItem.tree_name as clsName , brandItem.name as brandName , goods.* from goods goods " +
            "       left join tClsItem clsItem on goods.cls_code = clsItem.code and clsItem.status = '0'" +
            "       left join brandItem brandItem on goods.brand_code = brandItem.Code and brandItem.status = '0' " +
            " ${ew.customSqlSegment} ")
    IPage<Goods> selectPage(IPage<Goods> page, @Param("ew") Wrapper<Goods> queryWrapper);

    @Override
    @Select("select clsItem.code as \"clsItem.treeCode\" , clsItem.tree_name as \"clsItem.treeName\", " +
            " brandItem.code as \"brandItem.code\" , brandItem.name as \"brandItem.name\" , " +
            " clsItem.tree_name as clsName , brandItem.name as brandName , goods.* from goods goods " +
            "       left join tClsItem clsItem on goods.cls_code = clsItem.code and clsItem.status = '0'" +
            "       left join brandItem brandItem on goods.brand_code = brandItem.Code and brandItem.status = '0' " +
            " ${ew.customSqlSegment} ")
    Goods selectOne(@Param("ew")Wrapper<Goods> queryWrapper);

    @Override
    @Select("select clsItem.code as \"clsItem.treeCode\" , clsItem.tree_name as \"clsItem.treeName\", " +
            " brandItem.code as \"brandItem.code\" , brandItem.name as \"brandItem.name\" , " +
            " clsItem.tree_name as clsName , brandItem.name as brandName , goods.* from goods goods " +
            "       left join tClsItem clsItem on goods.cls_code = clsItem.code and clsItem.status = '0'" +
            "       left join brandItem brandItem on goods.brand_code = brandItem.Code and brandItem.status = '0' " +
            " where goods.id = #{id}")
    Goods selectById(@Param("id")Serializable id);

    String excelImport(Goods goods);
}
